﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*
 * Coder:Tieria
 * WriteTime:2015.5.13
 * FileName:MyX509Validator.cs
 * ReMark:X509证书认证,需要获取x509证书的密钥结果,然后进行匹配
 */
namespace FileDFS.Utils
{
    public class MyX509Validator : System.IdentityModel.Selectors.X509CertificateValidator
    {
        public override void Validate(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate)
        {
            if (certificate == null)
            {
                throw new ArgumentNullException("X509认证证书为空！");
            }
            if (certificate.Thumbprint.ToLower() != "‎‎c67f4a62cdd110eb7b59bbe51b63698ba11376c1".ToUpper())
            {
                throw new System.IdentityModel.Tokens.SecurityTokenException("Certificate Validation Error!");
            }
        }
    }
}
